package com.examstack.portal.persistence;

import java.util.List;

import com.examstack.common.domain.question.*;
import org.apache.ibatis.annotations.Param;

import com.examstack.common.util.Page;

/**
 * @author Ocelot
 * @date 2014年6月8日 下午8:32:33
 */
public interface QuestionMapper {

	public List<QuestionType> getQuestionTypeList();

	public Question getQuestionByQuestionId(@Param("questionId") int questionId);

	/**
	 * 获取某一题型的试题
	 * 
	 * @param QuestionTypeId
	 * @param page
	 * @return
	 */
	public List<Question> getQuestionByTypeId(@Param("QuestionTypeId") int QuestionTypeId,
			@Param("page") Page<Question> page);

	/**
	 * 按知识点获取试题
	 * 
	 * @param idList
	 * @return
	 */
	List<QuestionStruts> getQuestionListByPointId(@Param("array") List<Integer> idList);

	/**
	 * 根据试题类型和知识点获取试题
	 * 
	 * @param typeId
	 * @param pointId
	 * @return
	 */
	List<QuestionQueryResult> getQuestionAnalysisListByPointIdAndTypeId(@Param("typeId") int typeId,
			@Param("pointId") int pointId);

	/**
	 * 根据试题id获取试题清单
	 * 
	 * @param idList
	 * @return
	 */
	List<QuestionQueryResult> getQuestionAnalysisListByIdList(@Param("array") List<Integer> idList);

	/**
	 * 获取所有的Field
	 * 
	 * @param page
	 * @return
	 */
	public List<Field> getAllField(@Param("page") Page<Field> page);

	/**
	 * 获取Field下的知识点
	 * 
	 * @param fieldIdList
	 *            为null则获取所有知识点
	 * @param page
	 * @return
	 */
	public List<KnowledgePoint> getKnowledgePointByFieldId(@Param("array") int[] fieldIdList,
			@Param("page") Page<KnowledgePoint> page);



	public List<KnowledgePoint> getKnowledgePoint(
			@Param("fieldId") int fieldId,
			@Param("page") Page<KnowledgePoint> page);

	/**
	 * 按专业获取试题
	 * 
	 * @param fieldId
	 * @param page
	 * @return
	 */
	public List<QuestionQueryResult> getQuestionListByFieldId(@Param("fieldId") int fieldId,
			@Param("page") Page<QuestionQueryResult> page);
	
	/**
	 * 根据fieldId,pointId分组统计试题数量
	 * @param fieldId
	 * @return
	 */
	public List<QuestionStatistic> getQuestionStaticByFieldId(int fieldId);
	
	/**
	 * 根据fieldId,pointId,typeId分组统计试题数量
	 * @param fieldId
	 * @return
	 */
	public List<QuestionStatistic> getTypeQuestionStaticByFieldId(int fieldId);

	public void insertQuestion(Question question) throws Exception;
	public void addQuestionKnowledgePoint(@Param("questionId") int questionId,
										  @Param("pointId") int pointId) throws Exception;

	public List<Question> getQuestionList(
			@Param("filter") QuestionFilter filter,
			@Param("page") Page<Question> page);

	/**
	 * 获取所有标签
	 * @return
	 */
	public List<Tag> getTags(@Param("page") Page<Tag> page);

	/**
	 * 获取试题的知识点
	 * @param questionId
	 */
	public List<KnowledgePoint> getQuestionPoint(int questionId);

	/**
	 * 获取试题的tag
	 * @param questionId
	 * @param userId
	 * @param page
	 * @return
	 */
	public List<QuestionTag> getQuestionTagByQuestionIdAndUserId(
			@Param("questionId") int questionId, @Param("userId") int userId,
			@Param("page") Page<QuestionTag> page);

	/**
	 * 更新一道试题
	 * @param question Object为null，int＝0则不更新
	 */
	public void updateQuestion(Question question);

	public void deleteQuestionPointByQuestionId(
			@Param("questionId") int questionId) throws Exception;

	public void deleteQuestionTag(@Param("questionId") int questionId,@Param("userId") int userId,@Param("array") List<Integer> array);

	public void addQuestionTag(@Param("array") List<QuestionTag> array);

	public void deleteByQuestionId(Question question);
	//统计已发布且有异议的试题数量
	public List<QuestionStatistic> getSignQuestion(@Param("dissent") int dissent,@Param("visible")int visible);

	public List<Question> getQuestionListByContent(@Param("content") String content,@Param("fieldId") int fieldId);
}
